package com.bw.lib_mvvm

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import kotlinx.coroutines.launch

abstract class BaseMVVMActivity:AppCompatActivity() {

    protected val handler: Handler = Handler(Looper.getMainLooper())
//    private lateinit var netBroadCastReceiver:NetBroadCastReceiver
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(generateContentView())

        initView()
        initData()
        initEvent()


    }

    override fun onStop() {
        super.onStop()
        releaseRes()
    }

    /**
     * 释放资源
     */
    abstract fun releaseRes()

    /**
     * 初始化视图
     */
    protected open fun initView() {

    }

    /**
     * 创建content view
     */
    abstract fun generateContentView(): View

    /**
     * 初始化加载数据
     */
    abstract fun initData()

    /**
     * 初始化事件
     */
    abstract fun initEvent()



}